package org.example.pojo;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.anno.State;
import org.hibernate.validator.constraints.URL;

/**
 * 
 * @TableName article
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Article implements Serializable {
    /**
     * ID
     */
    @NotNull(groups = update.class)
    private Integer id;

    /**
     * 文章标题
     */
    @NotEmpty
    @Pattern(regexp = "^\\S{1,10}$",groups = add.class)
    private String title;

    /**
     * 文章内容
     */
    @NotEmpty
    private String content;

    /**
     * 文章封面
     */
    @NotEmpty
    @URL(groups = add.class)
    private String coverImg;

    /**
     * 文章状态: 只能是[已发布]或者[草稿]
     */
    @NotEmpty(groups = update.class)
    @State(groups = add.class)
    private String state;

    /**
     * 文章分类ID
     */
    @NotNull
    private Integer categoryId;

    /**
     * 创建人ID
     */
    private Integer createUser;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    private static final long serialVersionUID = 1L;

    private interface add extends Default {}

    private interface update{}
}